#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int UTC, BJT, hour, minute;
	scanf("%d", &UTC);
	if (UTC < 0 || UTC>2359) {
	}
	else {
		hour = UTC / 100;
		minute = UTC % 100;
		if (hour - 8 < 0)
		{
			hour += 16;
			printf("%d", hour * 100 + minute);
		}
		else {
			hour -= 8;
			printf("%d", hour * 100 + minute);
		}
	}
	return 0;
}